package net.xiaoyu233.mitemod.miteite.trans.entity;

import net.minecraft.*;
import net.xiaoyu233.mitemod.miteite.util.ParticleUtils;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;

@Mixin(EntityAnimal.class)
public abstract class EntityAnimalTrans extends EntityAgeable {
    public EntityAnimalTrans(World par1World) {
        super(par1World);
    }

    @Shadow
    public abstract void setAttackTarget(EntityLiving par1EntityLivingBase);

    public int getBreedExp() {
        return this.getRNG().nextInt(7) + 1;
    }

    @Inject(method = "attackEntityFrom", at = @At(value = "INVOKE", target = "Lnet/minecraft/EntityAgeable;attackEntityFrom(Lnet/minecraft/Damage;)Lnet/minecraft/EntityDamageResult;", shift = At.Shift.AFTER))
    public void injectAttackEntityFrom(Damage damage, CallbackInfoReturnable<EntityDamageResult> cir) {
        Entity entity = this;
        World world = worldObj;
        // 血液喷溅效果
        if (damage.getAmount() > 0) {
            if (!world.isRemote){
                // 使用安全的方法创建血液效果
//               this.entityFX(EnumEntityFX.splash);

                ParticleUtils.spawblood(world,61,posX,posY+1,posZ,Block.blockRedstone.blockID,entityId);
            }
        }
    }

}